/* =============================================================================
 * compare cross-sectional and life-cycle profiles
 * ===========================================================================*/

/*******************************************************************************
******************************** US (Figure 3a) ********************************
*******************************************************************************/

use "data\US.dta", clear

drop if outlier

drop if age < 24
drop if age > 60

keep if male == 1

recode year (1986/1990 = 1)(1991/1995 = 2)(1996/2000 = 3)	///
	(2001/2004 = 4)(2005/2008 = 5)(2009/2012 = 6), gen(yeargroup)	
	
recode ybirth (1930/1939 = 1935)(1940/1949 = 1945)(1950/1959 = 1955)		///
	(1960/1969 = 1965)(1970/1979 = 1975)(1980/1989 = 1985), gen(cohort)
	
twoway (lpolyci earn age if cohort == 1945 [aw = asecwt], clcolor(blue*0.2) fcolor(%30))	///
	(lpolyci earn age if cohort == 1955 [aw = asecwt], clcolor(blue*0.5) fcolor(%30))		///
	(lpolyci earn age if cohort == 1965 [aw = asecwt], clcolor(blue*0.75) fcolor(%30))		///
	(lpolyci earn age if cohort == 1975 [aw = asecwt], clcolor(blue*1) fcolor(%30))		///
	(lpolyci earn age if cohort == 1985 [aw = asecwt], clcolor(blue*1.5) fcolor(%30))		///
	(lpoly earn age if yeargroup == 6, clcolor(gray) lpattern(dash) fcolor(%30)),		///		
	xlabel(25(5)60, labsize(medium)) yscale(r(29000 61000)) ylabel(30000(10000)60000, labsize(medium)) ///
	ytitle("Annual Earnings (2015 USD)", size(medium))	xtitle("Age", size(medium))			///
	legend(order(- "Cohort:" 2 "1940-1949" 4 "1950-1959" 6 "1960-1969" 8 "1970-1979" 10 "1980-1989") rows(2) pos(6) size(medsmall))			///
	name(us_lc, replace) xsize(4)				

graph export "figures\us_life_cycle_earnings.pdf", as(pdf) replace

	
/*******************************************************************************
****************************** China (Figure 3b) *******************************
*******************************************************************************/

use "data\China.dta", clear

keep if inlist(prov,21,31,44,51)	// provinces covered in all years

drop if outlier
drop if age < 24
drop if age > 60
keep if male == 1

recode ybirth (1930/1939 = 1935)(1940/1949 = 1945)(1950/1959 = 1955)		///
	(1960/1969 = 1965)(1970/1979 = 1975)(1980/1989 = 1985), gen(cohort)

recode year (1986/1990 = 1)(1991/1995 = 2)(1996/2000 = 3)	///
	(2001/2004 = 4)(2005/2008 = 5)(2009/2012 = 6), gen(yeargroup)
	
twoway (lpolyci earn age if cohort == 1945, clcolor(red*0.2) fcolor(%30))	///
	(lpolyci earn age if cohort == 1955, clcolor(red*0.5) fcolor(%30))		///
	(lpolyci earn age if cohort == 1965, clcolor(red*0.75) fcolor(%30))		///
	(lpolyci earn age if cohort == 1975, clcolor(red*1) fcolor(%30))		///
	(lpolyci earn age if cohort == 1985, clcolor(red*1.5) fcolor(%30))			///
	(lpoly earn age if yeargroup == 6, clcolor(gray) lpattern(dash) fcolor(%30)),		///	
	xlabel(25(5)60, labsize(medium))  ylabel(, labsize(medium)) ///
	ytitle("Annual Earnings (2015 CNY)", size(medium))	xtitle("Age", size(medium))		///
	legend(order(- "Cohort:" 2 "1940-1949" 4 "1950-1959" 6 "1960-1969" 8 "1970-1979" 10 "1980-1989") rows(2) pos(6) size(medsmall))		///
	name(cn_lc, replace) xsize(4)				
	
graph export "figures\cn_life_cycle_earnings.pdf", as(pdf) replace

